package se.liu.oschi129.game.objects;

import se.liu.oschi129.animation.Animation;
import se.liu.oschi129.level.levelspace.LevelSpace;
import se.liu.oschi129.world.model.World;
import se.liu.oschi129.world.objects.WorldMovableObject;

/**
 * This is a dead ObjectPlayer. It will fall dead and be destroyed when the object is outside the world.
 * 
 * @author oschi129
 */
public class ObjectPlayerDead extends WorldMovableObject {

	/**
	 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	 * - - - - - - - - - - - - Constructors - - - - - - - - - - - 
	 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	 */
	
	public ObjectPlayerDead(Animation animation, double x, double y) {
		super(Type.SOFT, animation, true, x, y, 24,32);
		setHorizontalSpeed(2);
		setVerticalSpeed(-8);
	}
	
	/**
	 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	 * - - - - - - - - - - - Public methods - - - - - - - - - - 
	 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	 */
	
	@Override public void performStepAction(World world) {
		super.performStepAction(world);
		if (getPhysicalRules() == null) {
			setPhysicalRules(world.getPhysicalRules());
			setVerticalAcceleration(getPhysicalRules().getGravity());
		}
		if (getY() > world.getHeight())
			world.removeObjectSynchronized(this);
	}
	
	@Override public void performDestructionAction(World world) {
		world.clearSynchronized();
		LevelSpace.get("level00_death").createWorld(world, null);
	}
	
	
}
